﻿using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Bill.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.JSON;
using Kingdee.BOS.App.Data;
using System.Data;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Metadata;
namespace LiMinCRMPlugin
{
    /// <summary>
    /// 预计入表单插件      
    /// mey
    /// 2024年6月19日
    /// </summary>
    [System.ComponentModel.Description("预计入表单插件")]
    [HotUpdate]
    public class PreRecordedForm : AbstractBillPlugIn
    {
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            base.ButtonClick(e);
        }

        public override void EntityRowDoubleClick(EntityRowClickEventArgs e)
        {
            base.EntityRowDoubleClick(e);
            string InFid = "";
            if (e.Row >= 0)
            {
                InFid = this.View.Model.GetValue("F_QLTK_PoOrder", e.Row).ToString();
                if (InFid != "")
                {

                    string sql = @"/*dialect*/  select fid from T_PRD_MO where FBillNo='" + InFid + "'";
                    DataTable dt_UR = DBUtils.ExecuteDataSet(Context, sql).Tables[0];
                    if (dt_UR != null && dt_UR.Rows.Count > 0)
                    {
                        //以单据视图打开
                        BillShowParameter para = new BillShowParameter();
                        //para.OpenStyle.ShowType = ShowType.Modal;
                        //采购订单唯一标识
                        para.FormId = "PRD_MO";
                        //样式 view 查看
                        para.Status = OperationStatus.VIEW;
                        //要打开单据的FID
                        para.PKey = dt_UR.Rows[0][0].ToString();
                        //para.ParentPageId = this.View.ParentFormView.PageId;
                        this.View.ShowForm(para);
                    }
                }

            }
        }

    }
}
